import { Switch, Route, Redirect } from 'react-router-dom'
import React from 'react';
export default function RouterView(props: any) {
    return (
        <div className="view">
            <Switch>
                {props.Routers.map((item: any, index: number) => {
                    if (item.from) return <Redirect to={item.to} key={index}></Redirect>
                    if (item.to && !item.from) return <Redirect to={item.to} key={index}></Redirect>
                    return <Route path={item.path} render={(sel) => {
                        let Com = item.component
                        if (item.children) {
                            return <Com router={item.children} {...sel}></Com>
                        }
                        return <Com {...sel} />
                    }} key={index}></Route>
                })}
            </Switch>
        </div>
    )
}
